package com.example.administrator.myproject.Utils;

import android.util.Log;

import com.example.administrator.myproject.JavaBean.AllSorts;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2016/12/12.
 */

public class ParseJsonUtil {
    //解析数据
    public static List<AllSorts> ParseJsonUtil(String json) throws JSONException {
        List<AllSorts> list = new ArrayList<>();
        JSONObject jsonObject = new JSONObject(json);
        JSONArray jsonArray = jsonObject.getJSONArray("l");
        for (int i = 0; i < jsonArray.length(); i++) {
            JSONObject jsonObject1 = jsonArray.getJSONObject(i);

            //解析json的六个数据
            String imag = jsonObject1.optString("i");
            Log.i("TAG", "===imag" + imag);
            String name = jsonObject1.optString("n");
            Log.i("TAG", "===name" + name.toString());
            String ticket = jsonObject1.optString("s");
            String today = jsonObject1.optString("t");
            String VenName = jsonObject1.optString("VenName");
            String priceName = jsonObject1.optString("priceName");
            AllSorts allsort = new AllSorts(imag, name, ticket, today, VenName, priceName);
            Log.i("TAG", "=====allsort" + allsort.toString());
            list.add(allsort);
        }

        return list;
    }
}
